﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;

namespace DBSourceToolsLib.CodeParser
{
    public class ParseToken : ParseObject
    {
        public const int COMMA = 7;
        public const int EQUALS = 8;
        public const int COLON = 9;
        public const int STAR = 10;

        private static Hashtable m_KeywordHash;

        public ParseToken(char charValue, int iLineIdx, int iWordIdx)
            : base(ParseObject.UNKNOWN, ParseObject.TOKEN, false, iLineIdx, iWordIdx)
        {
            m_Value = ParseToken.computeValue(charValue);
            if (m_Value > 0)
                IsResolved = true;
            m_Data = charValue.ToString();
        }

        public static int computeValue(char charValue)
        {
            if (m_KeywordHash.ContainsKey(charValue.ToString()))
                return (int) m_KeywordHash[charValue.ToString()];
            return -1;
        }
        static ParseToken()
        {
            m_KeywordHash = new Hashtable();
            m_KeywordHash.Add(",", COMMA);
            m_KeywordHash.Add(";", COLON);
            m_KeywordHash.Add("=", EQUALS);
            m_KeywordHash.Add("*", STAR);
        }
        public bool IsLegal
        {
            get { return m_Value > 0; }
        }
    }
}
